From 5dd7e248061051acd692f78519c1094c090c7c50 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Fri, 30 Sep 2022 16:58:00 +0100 Subject: [PATCH] Clean up GtkAccessibleRange Coding style and documentation fixes. --- gtk/gtkaccessiblerange.c | 209 +++++++++++++++++++-------------------- gtk/gtkaccessiblerange.h | 135 ++++++++++++------------- 2 files changed, 167 insertions(+), 177 deletions(-) diff --git a/gtk/gtkaccessiblerange.c b/gtk/gtkaccessiblerange.c index a99d2b6a30..bbe673aa2d 100644 --- a/gtk/gtkaccessiblerange.c +++ b/gtk/gtkaccessiblerange.c @@ -1,105 +1,104 @@ -/* gtkaccessiblerange.c: Accessible range interface - * - * Copyright © 2022 Red Hat Inc. - * - * SPDX-License-Identifier: LGPL-2.1-or-later - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -/** - * GtkAccessibleRange: - * - * This interface describes range controls, e. g. controls which have a single - * value which can optionally be changed by the user. - * - * This interface is expected to be implemented by controls of the - * %GTK_ACCESSIBLE_ROLE_METER, %GTK_ACCESSIBLE_ROLE_PROGRESS_BAR, - * %GTK_ACCESSIBLE_ROLE_SCROLLBAR, %GTK_ACCESSIBLE_ROLE_SLIDER and %GTK_ACCESSIBLE_ROLE_SPIN_BUTTON - * role. If that is not the case, a warning will be issued at runtime. - * - * In addition to this interface, its implementors are expected to provide the - * correct values for the following properties: %GTK_ACCESSIBLE_PROPERTY_VALUE_MAX, - * %GTK_ACCESSIBLE_PROPERTY_VALUE_MIN and %GTK_ACCESSIBLE_PROPERTY_VALUE_NOW. - * - * For controls where a minimum increment makes no sense and which do not allow - * setting the current value from the user, the default implementation of this - * interface suffices. - * - * Since: 4.10 - */ - -#include "config.h" - -#include "gtkaccessiblerange.h" - -G_DEFINE_INTERFACE (GtkAccessibleRange, gtk_accessible_range, GTK_TYPE_ACCESSIBLE) - -static double -gtk_accessible_range_default_get_minimum_increment (GtkAccessibleRange *accessible_range) -{ - return 0.0; -} - -static gboolean -gtk_accessible_range_default_set_current_value (GtkAccessibleRange *accessible_range, double value) -{ - return FALSE; -} - -static void -gtk_accessible_range_default_init (GtkAccessibleRangeInterface *iface) -{ - iface->get_minimum_increment = gtk_accessible_range_default_get_minimum_increment; - iface->set_current_value = gtk_accessible_range_default_set_current_value; -} - - /* - * gtk_accessible_range_get_minimum_increment: - * @self: a `GtkAccessibleRange` - * - * Returns the minimum increment which this `GtkAccessibleRange` supports. - * - * Returns: the minimum increment, or 0.0 if not overridden - * - * Since: 4.10 - */ -double -gtk_accessible_range_get_minimum_increment (GtkAccessibleRange *self) -{ - g_return_val_if_fail (GTK_IS_ACCESSIBLE_RANGE (self), .0); - - return GTK_ACCESSIBLE_RANGE_GET_IFACE (self)->get_minimum_increment (self); -} - - /* - * gtk_accessible_range_set_current_value: - * @self: a `GtkAccessibleRange` - * - * Sets the current value of this `GtkAccessibleRange` to @value. - * Note that for some widgets implementing this interface, setting a value - * through the accessibility API makes no sense, so calling this function may - * in some cases do nothing. - * @returns: %true if the call changed the value, %false otherwise - * - * Since: 4.10 - */ -gboolean -gtk_accessible_range_set_current_value (GtkAccessibleRange *self, double value) -{ - g_return_val_if_fail (GTK_IS_ACCESSIBLE_RANGE (self), FALSE); - - GtkAccessibleRangeInterface *iface = GTK_ACCESSIBLE_RANGE_GET_IFACE (self); - return iface->set_current_value (self, value); -} \ No newline at end of file +/* gtkaccessiblerange.c: Accessible range interface + * + * SPDX-FileCopyrightText: 2022 Red Hat Inc. + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +/** + * GtkAccessibleRange: + * + * This interface describes ranged controls, e.g. controls which have a single + * value within an allowed range and that can optionally be changed by the user. + * + * This interface is expected to be implemented by controls using the following + * roles: + * + * - `GTK_ACCESSIBLE_ROLE_METER` + * - `GTK_ACCESSIBLE_ROLE_PROGRESS_BAR` + * - `GTK_ACCESSIBLE_ROLE_SCROLLBAR` + * - `GTK_ACCESSIBLE_ROLE_SLIDER` + * - `GTK_ACCESSIBLE_ROLE_SPIN_BUTTON` + * + * If that is not the case, a warning will be issued at run time. + * + * In addition to this interface, its implementors are expected to provide the + * correct values for the following properties: + * + * - `GTK_ACCESSIBLE_PROPERTY_VALUE_MAX` + * - `GTK_ACCESSIBLE_PROPERTY_VALUE_MIN` + * - `GTK_ACCESSIBLE_PROPERTY_VALUE_NOW` + * - `GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT` + * + * For controls where a minimum increment makes no sense and which do not allow + * setting the current value from the user, the default implementation of this + * interface suffices. + * + * Since: 4.10 + */ + +#include "config.h" + +#include "gtkaccessiblerange.h" + +G_DEFINE_INTERFACE (GtkAccessibleRange, gtk_accessible_range, GTK_TYPE_ACCESSIBLE) + +static double +gtk_accessible_range_default_get_minimum_increment (GtkAccessibleRange *accessible_range) +{ + return 0.0; +} + +static gboolean +gtk_accessible_range_default_set_current_value (GtkAccessibleRange *accessible_range, double value) +{ + return FALSE; +} + +static void +gtk_accessible_range_default_init (GtkAccessibleRangeInterface *iface) +{ + iface->get_minimum_increment = gtk_accessible_range_default_get_minimum_increment; + iface->set_current_value = gtk_accessible_range_default_set_current_value; +} + +/** + * gtk_accessible_range_get_minimum_increment: + * @self: a `GtkAccessibleRange` + * + * Returns the minimum increment which this `GtkAccessibleRange` supports. + * + * Returns: the minimum increment, or 0.0 if not overridden + * + * Since: 4.10 + */ +double +gtk_accessible_range_get_minimum_increment (GtkAccessibleRange *self) +{ + g_return_val_if_fail (GTK_IS_ACCESSIBLE_RANGE (self), .0); + + return GTK_ACCESSIBLE_RANGE_GET_IFACE (self)->get_minimum_increment (self); +} + +/** + * gtk_accessible_range_set_current_value: + * @self: a `GtkAccessibleRange` + * + * Sets the current value of this `GtkAccessibleRange` to the given value + * + * Note that for some widgets implementing this interface, setting a value + * through the accessibility API makes no sense, so calling this function + * may in some cases do nothing + * + * Returns: true if the call changed the value, and false otherwise + * + * Since: 4.10 + */ +gboolean +gtk_accessible_range_set_current_value (GtkAccessibleRange *self, double value) +{ + g_return_val_if_fail (GTK_IS_ACCESSIBLE_RANGE (self), FALSE); + + GtkAccessibleRangeInterface *iface = GTK_ACCESSIBLE_RANGE_GET_IFACE (self); + + return iface->set_current_value (self, value); +} diff --git a/gtk/gtkaccessiblerange.h b/gtk/gtkaccessiblerange.h index afd2f9af7e..903bfb5685 100644 --- a/gtk/gtkaccessiblerange.h +++ b/gtk/gtkaccessiblerange.h @@ -1,72 +1,63 @@ -/* gtkaccessiblerange.h: Accessible range interface - * - * Copyright © 2022 Red Hat Inc. - * - * SPDX-License-Identifier: LGPL-2.1-or-later - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -#pragma once - -#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include - -G_BEGIN_DECLS -#define GTK_TYPE_ACCESSIBLE_RANGE (gtk_accessible_range_get_type()) - -GDK_AVAILABLE_IN_4_10 -G_DECLARE_INTERFACE (GtkAccessibleRange, gtk_accessible_range, GTK, ACCESSIBLE_RANGE, GtkAccessible) - -struct _GtkAccessibleRangeInterface -{ - GTypeInterface g_iface; - - /** - * GtkAccessibleRangeInterface::get_minimum_increment: - * @self: a `GtkAccessibleRange` - * - * Returns the minimum increment for this `GtkAccessibleRange`. - * The default implementation returns 0.0, which indicates that a minimum - * increment does not make sense for this implementation. - * Returns: the minimum increment - * - * Since: 4.10 - */ - double (* get_minimum_increment) (GtkAccessibleRange *self); - /** - * GtkAccessibleRangeInterface::set_current_value: - * @self: a `GtkAccessibleRange` - * @value: the value to set - * - * Sets the current value of @self to @value. - * This operation should behave similarly as if the user performed the action. - * Returns: %true if the operation was performed, %false otherwise - * - * Since: 4.10 - */ - gboolean (* set_current_value) (GtkAccessibleRange *self, double value); -}; - -GDK_AVAILABLE_IN_4_10 -double gtk_accessible_range_get_minimum_increment (GtkAccessibleRange *self); - -GDK_AVAILABLE_IN_4_10 -gboolean gtk_accessible_range_set_current_value (GtkAccessibleRange *self, double value); - -G_END_DECLS \ No newline at end of file +/* gtkaccessiblerange.h: Accessible range interface + * + * SPDX-FileCopyrightText: 2022 Red Hat Inc. + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#pragma once + +#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS +#define GTK_TYPE_ACCESSIBLE_RANGE (gtk_accessible_range_get_type()) + +GDK_AVAILABLE_IN_4_10 +G_DECLARE_INTERFACE (GtkAccessibleRange, gtk_accessible_range, GTK, ACCESSIBLE_RANGE, GtkAccessible) + +struct _GtkAccessibleRangeInterface +{ + GTypeInterface g_iface; + + /** + * GtkAccessibleRangeInterface::get_minimum_increment: + * @self: a `GtkAccessibleRange` + * + * Returns the minimum increment for this `GtkAccessibleRange`. + * The default implementation returns 0.0, which indicates that a minimum + * increment does not make sense for this implementation. + * Returns: the minimum increment + * + * Since: 4.10 + */ + double (* get_minimum_increment) (GtkAccessibleRange *self); + /** + * GtkAccessibleRangeInterface::set_current_value: + * @self: a `GtkAccessibleRange` + * @value: the value to set + * + * Sets the current value of @self to @value. + * + * This operation should behave similarly as if the user performed the + * action. + * + * Returns: true if the operation was performed, false otherwise + * + * Since: 4.10 + */ + gboolean (* set_current_value) (GtkAccessibleRange *self, + double value); +}; + +GDK_AVAILABLE_IN_4_10 +double gtk_accessible_range_get_minimum_increment (GtkAccessibleRange *self); + +GDK_AVAILABLE_IN_4_10 +gboolean gtk_accessible_range_set_current_value (GtkAccessibleRange *self, + double value); + +G_END_DECLS -- 2.30.2